---
layout: "default"
title: "String.UnicodeScalarView.Index"
description: "Swift documentation for 'String.UnicodeScalarView.Index': A position in a string&#39;s UnicodeScalars view."
keywords: "String.UnicodeScalarView.Index,struct,swift,documentation,<,=="
root: "/v3.0"
---

<div class="intro-declaration"><code class="language-swift">struct String.UnicodeScalarView.Index</code></div>

<div class="discussion comment">
    <p>A position in a string&#39;s <code>UnicodeScalars</code> view.</p>

<p>You can convert between indices of the different string views by using
conversion initializers and the <code>samePosition(in:)</code> method overloads.
The following example finds the index of the solid heart pictograph in
the string&#39;s character view and then converts that to the same
position in the Unicode scalars view:</p>

<pre><code class="language-swift">let hearts = &quot;Hearts &lt;3 ♥︎ 💘&quot;
let i = hearts.characters.index(of: &quot;♥︎&quot;)!

let j = i.samePosition(in: hearts.unicodeScalars)
print(hearts.unicodeScalars.suffix(from: j))
// Prints &quot;♥︎ 💘&quot;
print(hearts.unicodeScalars[j].value)
// Prints &quot;9829&quot;</code></pre>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">Comparable, Equatable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>



<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>







<h3>Instance Methods</h3>
<div class="declaration" id="func-lt_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-lt_rhs_">func &lt;(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-lt_rhs_"><div class="p">
    <p>Returns a Boolean value indicating whether the value of the first
argument is less than that of the second argument.</p>

<p>This function is the only requirement of the <code>Comparable</code> protocol. The
remainder of the relational operator functions are implemented by the
standard library for any type that conforms to <code>Comparable</code>.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A value to compare.
  <strong>rhs:</strong> Another value to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &lt;(lhs: String.UnicodeScalarView.Index, rhs: String.UnicodeScalarView.Index) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-eqeq_rhs_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-eqeq_rhs_">func ==(<wbr>_:<wbr>rhs:)</a>
        
<div class="comment collapse" id="comment-func-eqeq_rhs_"><div class="p">
    <p>Returns a Boolean value indicating whether two values are equal.</p>

<p>Equality is the inverse of inequality. For any values <code>a</code> and <code>b</code>,
<code>a == b</code> implies that <code>a != b</code> is <code>false</code>.</p>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> A value to compare.
  <strong>rhs:</strong> Another value to compare.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func ==(lhs: String.UnicodeScalarView.Index, rhs: String.UnicodeScalarView.Index) -&gt; Bool</code>
    
    
</div></div>
</div>


